
/*****************************************************************************************
Replication Code & Data (25 October 2017)
*Morse, Yonatan. "Presidential Power and the Impact of Repeated Elections in Africa" 
*All anlaysis was conducted on Stata 14
*Filename: Democratization_Elections.do
*Date Used: Democratization_Elections_File1.dta & Democratization_Elections_File2.dta
*Data Note: Variable definitions can be found using Stata's describe and in the accompanying codebook (Repeated_Elections.pdf)

******************************************************************************************/


/****************************************************************************
Figure 1: Presidential Power, Cumulative Elections, and Democratic Indicators
*****************************************************************************/

use Democratization_Elections_File1.dta

sum v2elpeace v2elboycot v2elfrfair v2eltrnout v2elaccept v2elvotlrg v2elvotsml v2ellovtlg v2ellovtsm v2elprescumul v2elprescons v2ellocumul v2ellocons v2ellostsl v2ellostss
preserve
graph drop _all
collapse (mean) v2eltrnout (mean) v2elboycot (mean)v2elvotlrg (mean)v2ellostsl (mean) v2eltvrexo (mean) v2eltvrig (mean)v2elaccept (mean) v2elpeace (mean) v2elfrfair (mean) v2x_civlib, by(el_cum2 PRES)            
xtset PRES el_cum2
xtline v2eltrnout, overlay name (g1)
xtline v2elboycot, overlay name (g2)
xtline v2elvotlrg, overlay name (g4)
xtline v2ellostsl, overlay name (g5)
xtline v2elaccept, overlay name (g6)
xtline v2elpeace, overlay name   (g7)
xtline v2elfrfair, overlay name (g8)
xtline v2x_civlib, overlay name (g9)
grc1leg g1 g2 g4 g5 g6 g7 g8 g9


/****************************************************************************
Table 1: Presidential Power and Socialization by Elections 
*****************************************************************************/
xtmixed v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq||ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_Table2.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label replace
xtmixed v2x_clpriv el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq||ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_Table2.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2x_cspart el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq||ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_Table2.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2xeg_eqprotec el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq||ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_Table2.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append


/****************************************************************************
Figure 2: Presidential Power and Socialization by Elections 
*****************************************************************************/
graph drop _all
xtmixed v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq|| ccode: el_cum, cov(un) mle
quietly margins, at (prespow=(0(.1)1) el_cum=(4)) atmeans
marginsplot, recast(line) recastci(rline) name(a)
quietly margins, at (prespow=(0(.1)1) el_cum=(8)) atmeans
marginsplot, recast(line) recastci(rline) name(b)
quietly margins, at (prespow=(0.5) el_cum=(0(1)8)) atmeans
marginsplot, recast(line) recastci(rline) name(c)
quietly margins, at (prespow=(1) el_cum=(0(1)8)) atmeans
marginsplot, recast(line) recastci(rline) name(d)
grc1leg a b c d

/*********************************
APPENDIXES
********************************/

/********************************
Supporting Information: Appendix C. Summary Statistics
*******************************/
sum v2x_civlib v2x_clpriv v2x_cspart v2x_gender v2x_egal el_cum prespow1 prespow2 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd v2x_civlib v2elfrfair v2elpeace v2elaccept v2ellostsl v2elvotlrg v2elboycot v2eltrnout
outreg2 using Democratization_Elections_AppendixC.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(3) label replace

/********************************************************************************
Supporting Information: Appendix D. Socialization by Elections with PRESPOW2
*******************************************************************************/
xtmixed v2x_civlib el_cum prespow2 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq|| ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixD.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label replace
xtmixed v2x_clpriv el_cum prespow2 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg  musmaj stock_fnd  non_elec el_cum_sq || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixD.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2x_cspart el_cum prespow2 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd  non_elec el_cum_sq  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixD.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2xeg_eqprotec el_cum prespow2 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd  non_elec el_cum_sq  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixD.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append

/*******************************************************************************************************************
Supporting Information: Appendix E. Socialization by Elections with an Alternative Measure of Ethnic Diversity
********************************************************************************************************************/
xtmixed v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI eth_a musmaj stock_fnd non_elec el_cum_sq|| ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixE.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label replace
xtmixed v2x_clpriv el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI eth_a  musmaj stock_fnd  non_elec el_cum_sq || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixE.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2x_cspart el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI eth_a musmaj stock_fnd  non_elec el_cum_sq  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixE.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2xeg_eqprotec el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI eth_a musmaj stock_fnd  non_elec el_cum_sq  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixE.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append

/*******************************************************************************************************************
Supporting Information: Appendix F. Socialization by Elections with a Measure of Free Elections
********************************************************************************************************************/

xtmixed v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec el_cum_sq v2xel_frefair|| ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixF.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label replace
xtmixed v2x_clpriv el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg  musmaj stock_fnd  non_elec el_cum_sq v2xel_frefair || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixF.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2x_cspart el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd  non_elec el_cum_sq v2xel_frefair  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixF.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
xtmixed v2xeg_eqprotec el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd  non_elec el_cum_sq v2xel_frefair  || ccode: el_cum, cov(un) mle
outreg2 using Democratization_Elections_AppendixF.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append


/******************************************************************************************
Supporting Information: Appendix G. Protection of Civil Liberties with Alternative Model Estimation
*******************************************************************************************/
*Pooled OLS
reg v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec, vce(cluster ccode)
outreg2 using Democratization_Elections_AppendixG.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label replace
*Fixed Effects
xtreg v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec, fe
outreg2 using Democratization_Elections_AppendixG.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
*Dynamic Panel using GMM
xtabond2 v2x_civlib l.v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec, gmm(v2x_civlib, l(2 1)) iv(el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec)
outreg2 using Democratization_Elections_AppendixG.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append
*Hausman-Taylor w/ endogenous laga
xthtaylor v2x_civlib l.v2x_civlib el_cum prespow1 yrsoffc GDP_cap_const GDP_cap_growth ODA_GNI ethpreg musmaj stock_fnd non_elec, endog (l.v2x_civlib)
outreg2 using Democratization_Elections_AppendixG.doc, aster(coef) alpha (0.001, 0.01, 0.05) dec(2) label append









